<?php
/* @var $this PartyController */
/* @var $model Party */

$this->breadcrumbs=array(
	'[用户]管理'=>array('admin'),
	'批量导入[用户]',
);

//设置页面标题
$this->pageTitle=Yii::app()->name.' - 添加[用户]';
$this->contentTitle='批量导入[用户]';
?>
<?php 
    if (isset($type)){
        if($type>0){
            echo ' <button type="button" class="but" onclick="javascript :history.go(-1);">返回</button>';
        }        
    }
?>   
<!--表单内容-->
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'party-form',
	'enableAjaxValidation'=>false,
        'enableClientValidation'=>true,
        'clientOptions'=>array(
            'validateOnSubmit'=>true
        ),
    'htmlOptions'=>array('class'=>'ajax_form'),
)); ?>
<script type="text/javascript" src="<?php echo Yii::app()->baseUrl?>/editor/kindeditor-min.js"></script>
<link rel="stylesheet" href="<?php echo Yii::app()->baseUrl?>/editor/themes/default/default.css" />


<table cellspacing="1" class="myform">
        <tr style="display: none;">
            <td align="right">ad_id</td>
            <td><input name="ad_id" value="<?php echo $ad_id; ?>"/></td>
        </tr>
        <tr>
		<td align="right"><?php echo $form->labelEx($model,'ad_id'); ?></td>
		<td>
			<?php echo CHtml::dropDownList('idProvince', '', CHtml::listData(CActiveRecord::model('Activity')->findAll(), 'id', 'title'),
                                array(
                                    'prompt' => '--选择活动--',
                                    'ajax' => array(
                                        'type' => 'POST',
                                        'url' => $this->createUrl('adlist'),
                                        'dataType' => 'json',
                                        'data' => array('aid' => 'js:this.value'),
                                        'success' => 'function(data) {
                                                        $("#Party_ad_id").html(data.dropDownCities);
                                                        $("#Party_line_id").html(data.dropDownDistricts);
                                                    }',
                                    )));?> 
			
		</td>
        </tr>
        <tr>
		<td align="right"><label>活动时间</label></td>
		<td>
                    
                    <?php
                    echo $form->dropDownList($model,'ad_id',  array(),
                        array(
                            'prompt' => '--请选择活动时间--',
                            'style'=>'float: left;',
                            'ajax' => array(
                                'type' => 'POST',
                                'url' => $this->createUrl('updateLine'),
                                'update' => '#Party_line_id',
                                'data' => array('ad_id' => 'js:this.value'),
                            )));
                    
                    ?> 
                    <?php echo $form->error($model,'ad_id'); ?>
                </td>
         </tr>
         
         <tr>
		<td align="right"><?php echo $form->labelEx($model,'line_id'); ?></td>
		<td>
			<?php echo $form->dropDownList($model,'line_id', array(), array('prompt' => '--选择上车地址--'));?> 
			
		</td>
        </tr>

	<tr>
		<td align="right"><?php echo $form->labelEx($model,'crowd_id'); ?></td>
		<td>
			 <?php echo $form->dropDownList($model,'crowd_id',CHtml::listData(Crowd::model()->findAll(), 'id', 'title'),
                        array('empty'=>'-请选择-')); ?> 
			<?php echo $form->error($model,'crowd_id'); ?>
		</td>
	</tr>

	

	   <tr>
          <td align="right">导入文件：</td> 
          <td>
              <input class="ke-input-text" type="text" name="userfile" id="url" value="" readonly="readonly" />
                <input type="button" id="uploadButton" value="上传文件" />
          </td>
        </tr>

	<tr>
        <td align="right"></td>
        <td>
            <input class="but" type="submit" name="yt0" value="提 交" />        </td>
    </tr>
    
</table>
  <?php 
        if(Yii::app()->user->getFlash('upload_error')){
        echo "<script>art.dialog({icon:'error',content:'请选择上传文件！',time:2});</script>";
        }    
        if(Yii::app()->user->getFlash('code_error')){
        echo "<script>art.dialog({icon:'error',content:'身份证信息错误！',time:2});</script>";
        }           
    ?> 
<?php $this->endWidget(); ?>
<!--表单内容-->
<div>
<form class="ajax_form" enctype="multipart/form-data" name = "SubmitForm"
      action="<?php echo Yii::app()->baseUrl?>/index.php/party/batchCreate" id="party-form" method = "post">
    <table cellspacing="1" class="myform">
     
    </table>
</form>
</div>

<script>
	KindEditor.ready(function(K) {
                var uploadbutton = K.uploadbutton({
                        button : K('#uploadButton')[0],
                        fieldName : 'imgFile',
                        url : '<?php echo Yii::app()->baseUrl?>/editor/php/upload_json.php?dir=excel',
                        afterUpload : function(data) {
                                if (data.error === 0) {
                                       var url = K.formatUrl(data.url, 'absolute');
					K('#url').val(url);
                                } else {
                                        alert(data.message);
                                }
                        },
                        afterError : function(str) {
                                alert('自定义错误信息: ' + str);
                        }
                });
                uploadbutton.fileBox.change(function(e) {
                        uploadbutton.submit();
                });
                var uploadbuttons = K.uploadbutton({
                        button : K('#uploadButtons')[0],
                        fieldName : 'imgFile',
                        url : '<?php echo Yii::app()->baseUrl?>/editor/php/upload_json.php?dir=image',
                        afterUpload : function(data) {
                                if (data.error === 0) {
                                       var url = K.formatUrl(data.url, 'absolute');
					K('#Party_head_image').val(url);
                                } else {
                                        alert(data.message);
                                }
                        },
                        afterError : function(str) {
                                alert('自定义错误信息: ' + str);
                        }
                });
                uploadbuttons.fileBox.change(function(e) {
                        uploadbuttons.submit();
                });                
        });
</script>